package cn.wp.ewallet.common.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import cn.wp.common.core.util.BeanUtil;
import cn.wp.ewallet.common.dao.MoneyTypeInfoDao;
import cn.wp.ewallet.common.model.dto.MoneyTypeInfoDto;
import cn.wp.ewallet.common.model.entity.MoneyTypeInfoDoo;
import cn.wp.ewallet.common.service.MoneyTypeInfoService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * 币种信息-业务逻辑层实现
 * Created by zhangyongli on 2020/01/13
 */
@Service
public class MoneyTypeInfoServiceImpl implements MoneyTypeInfoService {

    @Autowired
    private MoneyTypeInfoDao moneyTypeInfoDao;

    @Override
    public List<MoneyTypeInfoDto> getMoneyTypeInfo() {
        return BeanUtil.listCopyProperties(moneyTypeInfoDao.selectMoneyTypeInfo(null), MoneyTypeInfoDto.class);
    }

    @Override
    public MoneyTypeInfoDto getMoneyTypeInfoByMoneyTypeId(String moneyTypeId) {
        List<MoneyTypeInfoDoo> list = moneyTypeInfoDao.selectMoneyTypeInfo(moneyTypeId);
        if (!CollectionUtil.isEmpty(list)) {
            return BeanUtil.copyProperties(list.get(0), MoneyTypeInfoDto.class);
        }
        return null;
    }
}
